<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="ZH-CN">
<head>
<title>指导教师分配设置</title>
<meta http-equiv="X-UA-Compatible" content="IE=9" >
<meta name="keywords" content="吉珠,吉林大学,吉林大学珠海学院,吉林大学珠海学院论文管理">
<meta name="content-type" content="text/html" charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="<%=request.getContextPath()%>/pages1/css/bootstrap.css" type="text/css">
<link rel="stylesheet" href="<%=request.getContextPath()%>/pages1/css/flow.css" type="text/css">
<script src="<%=request.getContextPath()%>/pages1/js/jquery-2.1.1.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/pages1/js/bootstrap.js" type="text/javascript"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/jquery-easyui-1.4.1/jquery.min.js"></script>
<link rel="stylesheet" href="<%=request.getContextPath()%>/jquery-easyui-1.4.1/themes/gray/easyui.css" type="text/css"></link>
<link rel="stylesheet" href="<%=request.getContextPath()%>/jquery-easyui-1.4.1/themes/icon.css" type="text/css"></link>
<script type="text/javascript" src="<%=request.getContextPath()%>/jquery-easyui-1.4.1/locale/easyui-lang-zh_CN.js"></script>
<style>
.col-xs-3 {
	padding: 1px;
	height: 1110px;
}
.col-xs-9 {
	height: 1110px;
}
#xs12 {
	height: 1004px;
	width: 313px;
}
</style>
<script type="text/javascript" language="javascript">
function g(o){return document.getElementById(o);}
function hoverli(n){
for(var i=1;i<=28;i++){
{g('tb_'+i).className='';}
g('tb_'+n).className='actived';}
}
function show(id){
var traget=document.getElementById(id);
traget.style.display="block"; 
}

function hide(id){
var traget=document.getElementById(id);
traget.style.display="none"; 
}

$(function(){
	tableTeacher();
	tableStudent();
	document.getElementById("oddAmount").value="";
	$('#teahcerList').combobox({
    	url:'<%=request.getContextPath()%>/setSecretary/teacherList',
		valueField:'teacher_id',
		textField:'teacher_name',
		});
	tableStudent();
	$('#teahcerList_no').combobox({
    	url:'<%=request.getContextPath()%>/setSecretary/teacherList_no',
		valueField:'teacher_id',
		textField:'teacher_name',
		onSelect:function(){
			$.ajax({
				url:'<%=request.getContextPath()%>/setSecretary/oddAmount',
				data:{
					"tchId": $('#teahcerList_no').combobox('getValue')
				},
				success:function(r){
					document.getElementById("oddAmount").value=r;
				}
			});
			},
		}); 
});

/**
*未分配完成师表格
**/
function tableTeacher_no(){
	console.info("2");
	var set_table= $('#resultTable').datagrid({
		url:'<%=request.getContextPath()%>/setSecretary/result_no',
//		title:'综合设置',
		pagination : true,
		pageSize : 5,
		pageList : [ 5],
		singleSelect : true,
		fitColumns : true,
		rownumbers : true,
		columns : [ [
				{
					title : '系名称',
					field : 'department_name',
					width : 100,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.department_name;
						return a;
					}
				},
				{
					title : '教师工号',
					field : 'teacher_no',
					width : 50,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.teacher_no;
						return a;
					}
				},
				{
					title : '教师姓名',
					field : 'teacher_name',
					width : 40,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.teacher_name;
						return a;
					}
				},
				{
					title : '专业方向',
					field : 'teacher_research',
					width : 50,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.teacher_research;
						return a;
					}
				},
				{
					title : '职称/职位',
					field : 'zhicheng_name',
					width : 50,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.zhicheng_name;
						return a;
					}
				},
				{
					title : '学历',
					field : 'teacher_xueli',
					width : 50,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.teacher_xueli;
						return a;
					}
				},
				{
					title : '指导学生数量',
					field : 'stuamount',
					width : 50,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.stuamount;
						return a;
					}
				},
				]],
	});
}


/**
*所有教师分配结果表格
**/
function tableTeacher(){
	console.info("1");
	var set_table= $('#resultTable').datagrid({
		url:'<%=request.getContextPath()%>/setSecretary/result_depId',
//		title:'综合设置',
		pagination : true,
		pageSize : 5,
		pageList : [ 5],
		singleSelect : true,
		fitColumns : true,
		rownumbers : true,
		columns : [ [
				{
					title : '系名称',
					field : 'department_name',
					width : 100,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.department_name;
						return a;
					}
				},
				{
					title : '教师工号',
					field : 'teacher_no',
					width : 50,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.teacher_no;
						return a;
					}
				},
				{
					title : '教师姓名',
					field : 'teacher_name',
					width : 40,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.teacher_name;
						return a;
					}
				},
				{
					title : '专业方向',
					field : 'teacher_research',
					width : 50,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.teacher_research;
						return a;
					}
				},
				{
					title : '职称/职位',
					field : 'zhicheng_name',
					width : 50,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.zhicheng_name;
						return a;
					}
				},
				{
					title : '学历',
					field : 'teacher_xueli',
					width : 50,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.teacher_xueli;
						return a;
					}
				},
				{
					title : '指导学生数量',
					field : 'stuamount',
					width : 50,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.stuamount;
						return a;
					}
				},
				]],
	});
}

/**
*某老师分配结果表格
**/
function searchTeacher()
{
//	var tchId = document.getElementsByName("teacherList");
	var tchId = $('#teahcerList').combobox('getValue');
	console.info(tchId);
	if(tchId==null || tchId=="")
	{
		table();
	}
	else
	{
			var set_table= $('#resultTable').datagrid({
		url:'<%=request.getContextPath()%>/setSecretary/result_teacher?tchId='+tchId+'',
//		title:'综合设置',
		pagination : true,
		pageSize : 5,
		pageList : [ 5],
		singleSelect : true,
		fitColumns : true,
		rownumbers : true,
		columns : [ [
				{
					title : '系名称',
					field : 'department_name',
					width : 100,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.department_name;
						return a;
					}
				},
				{
					title : '教师工号',
					field : 'teacher_no',
					width : 50,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.teacher_no;
						return a;
					}
				},
				{
					title : '教师姓名',
					field : 'teacher_name',
					width : 40,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.teacher_name;
						return a;
					}
				},
				{
					title : '专业方向',
					field : 'teacher_research',
					width : 50,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.teacher_research;
						return a;
					}
				},
				{
					title : '职称/职位',
					field : 'zhicheng_name',
					width : 50,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.zhicheng_name;
						return a;
					}
				},
				{
					title : '学历',
					field : 'teacher_xueli',
					width : 50,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.teacher_xueli;
						return a;
					}
				},
				{
					title : '指导学生数量',
					field : 'stuamount',
					width : 50,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.stuamount;
						return a;
					}
				},
				]],
	});
	}
}

/**
*分配学生表格
**/
function tableStudent()
{
	var set_table= $('#tableStudent').datagrid({
		url:'<%=request.getContextPath()%>/setSecretary/studentList',
//		title:'综合设置',
		pagination : true,
		pageSize : 5,
		pageList : [ 5],
//		singleSelect : true,
		fitColumns : true,
		rownumbers : true,
		toolbar:[{
					id:'btnadd',
					text:'选择',
					iconCls:'icon-add',
					handler:function(){
						var stuList =$('#tableStudent').datagrid('getChecked');
						var idList="";
						var tchId=$('#teahcerList_no').combobox('getValue');
						if(tchId=="" || tchId==null)
						{
							$.messager.alert('提示', '请选择老师');
						}
						else if(stuList==null || stuList=="")
						{
							$.messager.alert('提示', '请选择学生');
						}
						else
						{
							for(var i=0;i<stuList.length;i++)
							{
								idList=idList+stuList[i].student_id+",";
							}
							$.ajax({
								url:'<%=request.getContextPath()%>/setSecretary/allotStudent',
								data:{
									"stuId_List":idList,
									"tchId":tchId,
								},
								success: function(r) {
									$.messager.alert('提示', r.msg1+"<br>" + r.msg2+"<br>",'info',function() {
									javascript: window.location.reload();
								});
								},
							});
						}
					}
				}],
		frozenColumns:[[
	                {
	                field:'ck',
	                checkbox:true
	                },
				]],
		columns : [ [
				{
					title : '系名称',
					field : 'department_name',
					width : 100,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.department_name;
						return a;
					}
				},
				{
					title : '学生学号',
					field : 'student_no',
					width : 50,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.student_no;
						return a;
					}
				},
				{
					title : '学生姓名',
					field : 'student_name',
					width : 40,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.student_name;
						return a;
					}
				},
				{
					title : '专业方向',
					field : 'majordirection_name',
					width : 80,
					align : 'center',
					formatter : function(value, row, index) {
						var a = row.majordirection_name;
						return a;
					}
				},
				]],
	});
}

/**
*上传方法
**/
function uploadFile(form) {
      var path=form.inputfile.value;
         if(path==""){
      alert("请选择上传文件");
          return;
      }
     var index=path.lastIndexOf(".");
      var result =path.substr(index+1);
      //alert(result);
     
      if(result!="xls")
      {
        alert("请上传文件格式为xls的文件");
          return;
      }
      
      var traget=document.getElementById("butToprogress");
      traget.innerHTML= "<p align='center'><progress id='progressBar' value='0' max='100'></progress><span id='percentage'></span></p>";

        var fd = new FormData();
        fd.append("表格", document.getElementById('inputfile').files[0]);
        var xhr = new XMLHttpRequest();
        xhr.upload.addEventListener("progress", progressFunction, false);
        xhr.addEventListener("load", uploadComplete, false);
        xhr.addEventListener("error", uploadFailed, false);
        xhr.addEventListener("abort", uploadCanceled, false);
        xhr.open("POST", "<%=request.getContextPath()%>/setSecretary/importExcel");
        xhr.send(fd);
      }
      
        function progressFunction(evt) {

            var progressBar = document.getElementById("progressBar");

            var percentageDiv = document.getElementById("percentage");

            if (evt.lengthComputable) {

                progressBar.max = evt.total;

                progressBar.value = evt.loaded;

                percentageDiv.innerHTML = Math.round(evt.loaded / evt.total * 100) + "%";

            }

        }  
        
      function uploadComplete(evt) {
        /* This event is raised when the server send back a response */
       
      alert(evt.target.responseText);
      
     
            // file.outerHTML = file.outerHTML;  
      //$.messager.alert("操作提示", "成功");
     parent.location.reload();//刷新页面
      }

      function uploadFailed(evt) {
        alert("上传失败");
      }

      function uploadCanceled(evt) {
        alert("上传已经取消");
      }
      		function showWhat()
		{
			var collap=document.getElementById('collapseHelp');
			if(collap.style.display=='none')
				collap.style.display='block';
			else
				collap.style.display='none';
		}
</script>
</head>

<body>
<!--全局框架 开始 conteiner-->
<div class="container"> 
  <!--标题头图片-->
  <div class="row">
    <div class="body_top"> <img src="<%=request.getContextPath()%>/pages1/img/head.png" align="center" width="1280px"/> </div>
  </div>
  <!--全局12栅格 规划全局区域图线 开始 row+ col-->
  <div class="row">
    <jsp:include page="secretary_siderbar.jsp"></jsp:include>
        
                
        <!--左侧跳转框架结束--> 
<!--右侧用户操作模块 占全局9栅格-->
<div class="col-xs-9"style="border:2px solid #25465d">
        <div class="row">
            <div class="col-xs-4  xs11" style="margin-top:2px; margin-bottom:0px;"> <strong><font size="3">流程管理》指导教师分配设置	</font></strong> </div>
          </div>
                  <div class="col-xs-11  xs11" style="margin-top:2px; margin-bottom:0px;">
              <div class="panel panel-default" style="margin-top:2px; margin-bottom:10px;">
                <div class="panel-heading" align="left"> <a data-toggle="collapse" data-parent="#accordion"  href="#collapseHelp" class="glyphicon glyphicon-chevron-down" onclick="showWhat()"> 操作指南 </a> </div>
                <div id="collapseHelp" class="panel-collapse collapse">
                  <div class="panel-body">指导教师分配设置：
            <ul>
              <li>教学秘书可以通过查询按键查找某个教师目前学生选择导师的情况，并可以通过"未分配完毕教师"按键查看所有未分配完毕学生的教师，点击"所有教师"可以查看所有教师分配学生的情况。</li><br>
              <li>教师和学生可以双向选择，教师如果根据项目团队，已经有事先选择好的学生，可以下载指导教师的excel模板，填写教师和学生的关联内容，然后通过"教师分配学生设置2"的方案设置教师学生的关联关系，也可以将所有教师和学生的关联关系通过这个表事先设计好后，导入该教师与学生设置。</li><br><br>
              <li>对于部分没有被学生选择满额的教师以及部分没有选择指导教师的学生，教学秘书可以通过"教师分配学生设置1"来设置教师和学生的关联关系。</li>
            </ul> </div>
                </div>
        </div>
        <div class="col-xs-12" style="margin-top:5px; margin-bottom:10px;">
<p><b>教师分配学生查询</b></p>
             
<p>所属系名称:&nbsp&nbsp&nbsp&nbsp
                        <select disabled="disabled">
                          <option value="1">计算机科学与技术系</option>

                        </select> &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 
 
                        

               教师姓名：&nbsp&nbsp&nbsp&nbsp
               <input name="teahcerList" id="teahcerList" value=""/>
                        <br>
                        <div align="right">
                        <button type="button" class="btn btn-info btn-xs" onclick="searchTeacher()">&nbsp;&nbsp;查询&nbsp;&nbsp;</button> &nbsp&nbsp&nbsp&nbsp   
                        <button type="button" class="btn btn-info btn-xs" onclick="tableTeacher_no()">&nbsp;&nbsp;未分配完毕教师&nbsp;&nbsp;</button>&nbsp&nbsp&nbsp&nbsp 
                 <button type="button" onclick="tableTeacher()" class="btn btn-info btn-xs">&nbsp;&nbsp;所有教师&nbsp;&nbsp;</button>
                 </div>
                        </p> 
          
          
           <div class="row" align="center">
           <div class="col-xs-12" style="margin-bottom:0px; margin-top:0px;">
			<div class="panel panel-default"  margin-bottom:0px; margin-top:0px;">
			<div class="panel-body">
         
         <table id="resultTable" class="table table-hover table-bordered" style="margin-top:0px; margin-bottom:0px;">
 
          </table>

</div>
</div>
</div>
</div>
          </div>
          
		              <div class="col-xs-12">
		              <p>教师分配学生导入表： </p>  
    <form id="fileupload" action="${pageContext.request.contextPath}/setSecretary/importExcel_gTch_jTch" method="post" enctype="multipart/form-data">     
		 <div class="col-xs-8" style="border:1px solid #25465d ; background-color:#d8d8d8; width:300px;height:30px;">
		      <label class="sr-only" for="inputfile">文件输入</label>
		            <input type="file" id="inputfile">
		</div>
		  <div class="col-xs-4" >
		     <button type="button" class="btn btn-success btn-sm" onclick="uploadFile(fileupload)" value="刷新"/>导入设置</button> 
		     </div> 
		  </form> 
       <div id="butToprogress"></div>
       </div>

          <div class="col-xs-12">
          <p>
                                          指导教师姓名：&nbsp&nbsp&nbsp&nbsp
            <input name="teahcerList_no" id="teahcerList_no" value="" style="width: 100px"/>
          		指导教师剩余名额：&nbsp&nbsp&nbsp&nbsp
            <input name="oddAmount" id="oddAmount" value="" style="width: 50px" disabled="disabled"/>

                        </p> 
              <table class="table table-hover table-bordered" style="margin-top:0px; margin-bottom:0px;" id="tableStudent">

          </table>

          </div>
           </div>
      

 </div>
  </div><!--修改结束--> 
      </div>
      <!--全局12栅格 规划全局区域图线 结束 row+ col--> 
    </div>
 
  <div class="row" style="background-color:#25465d"">
    <p  align="center" style="color:white;background-color:#25465d"><strong>用户单位：</strong>吉林大学珠海学院&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>版权所有：</strong>吉林大学珠海学院计算机科学与技术系</p>
  </div>
  <!--全局框架结束 conteiner--> 
</div>
</body>
</html>
